<template>
	<div class="vistorContent">
		<div class="content">
			<el-form :model="form" label-width="auto" style="max-width: 600px">
			    <el-form-item label="姓名">
			      <el-input style="background: #ffffff96;" v-model="form.name" />
			    </el-form-item>
			    <el-form-item label="身份证号">
					<el-input style="background: #ffffff96;"  v-model="form.name" />
			      <!-- <el-select v-model="form.region" placeholder="please select your zone">
			        <el-option label="Zone one" value="shanghai" />
			        <el-option label="Zone two" value="beijing" />
			      </el-select> -->
			    </el-form-item>
			   <!-- <el-form-item label="Activity time">
			      <el-col :span="11">
			        <el-date-picker
			          v-model="form.date1"
			          type="date"
			          placeholder="Pick a date"
			          style="width: 100%"
			        />
			      </el-col>
			      <el-col :span="2" class="text-center">
			        <span class="text-gray-500">-</span>
			      </el-col>
			      <el-col :span="11">
			        <el-time-picker
			          v-model="form.date2"
			          placeholder="Pick a time"
			          style="width: 100%"
			        />
			      </el-col>
			    </el-form-item> -->
			    <!-- <el-form-item label="Instant delivery">
			      <el-switch v-model="form.delivery" />
			    </el-form-item> -->
			    <!-- <el-form-item label="Activity type">
			      <el-checkbox-group v-model="form.type">
			        <el-checkbox value="Online activities" name="type">
			          Online activities
			        </el-checkbox>
			        <el-checkbox value="Promotion activities" name="type">
			          Promotion activities
			        </el-checkbox>
			        <el-checkbox value="Offline activities" name="type">
			          Offline activities
			        </el-checkbox>
			        <el-checkbox value="Simple brand exposure" name="type">
			          Simple brand exposure
			        </el-checkbox>
			      </el-checkbox-group>
			    </el-form-item> -->
			    <!-- <el-form-item label="Resources">
			      <el-radio-group v-model="form.resource">
			        <el-radio value="Sponsor">Sponsor</el-radio>
			        <el-radio value="Venue">Venue</el-radio>
			      </el-radio-group>
			    </el-form-item> -->
			    <el-form-item label="身份证上传">
			      <el-upload
			          class="avatar-uploader"
			          action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15"
			          :show-file-list="false"
			          :on-success="handleAvatarSuccess"
			          :before-upload="beforeAvatarUpload"
			        >
			          <img v-if="imageUrl" :src="imageUrl" class="avatar" />
			          <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
			        </el-upload>
			    </el-form-item>
			    <el-form-item>
			      <el-button type="primary" @click="onSubmit">确定</el-button>
			      <!-- <el-button>Cancel</el-button> -->
			    </el-form-item>
			  </el-form>
		</div>
	</div>
</template>

<script lang="ts" setup>
	import { reactive,ref } from 'vue'
	
	// do not use same name with ref
	const form = reactive({
	  name: '',
	  region: '',
	  date1: '',
	  date2: '',
	  delivery: false,
	  type: [],
	  resource: '',
	  desc: '',
	})
	
	const onSubmit = () => {
	  console.log('submit!')
	}
	
	import { Plus } from '@element-plus/icons-vue'
	
	import type { UploadProps } from 'element-plus'
	
	const imageUrl = ref('')
	
	const handleAvatarSuccess: UploadProps['onSuccess'] = (
	  response,
	  uploadFile
	) => {
	  imageUrl.value = URL.createObjectURL(uploadFile.raw!)
	}
	
	const beforeAvatarUpload: UploadProps['beforeUpload'] = (rawFile) => {
	  if (rawFile.type !== 'image/jpeg') {
	    ElMessage.error('Avatar picture must be JPG format!')
	    return false
	  } else if (rawFile.size / 1024 / 1024 > 2) {
	    ElMessage.error('Avatar picture size can not exceed 2MB!')
	    return false
	  }
	  return true
	}
</script>

<style lang="scss" scoped>
	.vistorContent{
		width: 100%;
		height: 100%;
		background-image: url('/src/assets/images/zhaopin.jpg');
		background-size: cover;
	}
	.content{
		width: 1100px;
		height: 600px;
		background: rgba(255,255,255,.5);
		position: absolute;
		left: 0;
		right: 0;
		bottom: 0;
		top: 0;
		margin:auto;
		margin-top: 140px;
		backdrop-filter: blur(10px);
		border-radius: 8px;
	}
	.avatar-uploader .el-upload {
	  border: 1px dashed var(--el-border-color);
	  border-radius: 6px;
	  cursor: pointer;
	  position: relative;
	  overflow: hidden;
	  transition: var(--el-transition-duration-fast);
	}
	
	::v-deep .el-form{
		max-width: 500px!important;
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		margin: auto;
		margin-top: 100px;
	}
	
	.avatar-uploader .el-upload:hover {
	  border-color: var(--el-color-primary);
	}
	
	.el-icon.avatar-uploader-icon {
		    border: 1px dashed rgb(0 0 0 / 66%);
		    background: #ffffff96;
	  font-size: 28px;
	  color: #8c939d;
	  width: 178px;
	  height: 178px;
	  text-align: center;
	}
</style>